<?php

class CateAction extends Action {

	public function cate(){
		$cate = new Model('Cate');
		$item = new Model('Item');
		$id = intval($_GET['id']);
		$category = $cate->field('cate_id,cate_name')->select();
		$view = $item->where("cate_id='$id'")->select();
		$this->assign('cate',$category);
		$this->assign('view',$view);
		$this->display();

	}
	public function delete(){
		if(isset($_GET['c_id'])){
		$cate = new Model('Cate');
		$c_id = intval($_GET['c_id']);
		$cate->where("cate_id='$c_id'")->delete();
		$this->redirect('cate');
		}

		if(isset($_GET['i_id'])){
		$item = new Model('Item');
		$i_id = intval($_GET['i_id']);
		$list = $item->field('cate_id')->where("item_id='$i_id'")->select();
		$item->where("item_id='$i_id'")->delete();
		$this->redirect('cate',array('id'=>$list[0]['cate_id']),1,'页面跳转中~~~');
		}

	}
}
?>